unit Cons_LayOutChq;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Formulario_Padrao_Consulta, StdCtrls, Buttons, ExtCtrls, Grids, DBGrids,
  TFlatButtonUnit;

type
  TFrmCons_LayOutChq = class(TFrmConsulta)
    Label1: TLabel;
    ed_descricao: TEdit;
    DBGrid: TDBGrid;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure ed_descricaoKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure BtnFecharClick(Sender: TObject);
  private
    procedure faz_consulta;
  public
    { Public declarations }
  end;

var
  FrmCons_LayOutChq: TFrmCons_LayOutChq;
  xcons_layout: string;

implementation

uses clsLayOutChq, dm, db, dbtables;

var
  layout: TLayoutChq;
  tq: TQuery;
  tds: TDataSource;

{$R *.DFM}

procedure TFrmCons_LayOutChq.FormCreate(Sender: TObject);
begin
  inherited;
  layout := TLayoutChq.Create;
  tq := TQuery.Create(self);
  tds := TDataSource.Create(self);
end;

procedure TFrmCons_LayOutChq.FormDestroy(Sender: TObject);
begin
  inherited;
  layout.free;
  tq.free;
  tds.free;
end;

procedure TFrmCons_LayOutChq.FormActivate(Sender: TObject);
begin
  inherited;
  tq.databasename := dmint.db.databasename;
  tds.DataSet := tq;
  dbgrid.DataSource := tds;
  faz_consulta;
end;

procedure TFrmCons_LayOutChq.faz_consulta;
var
  xdesc: string;
begin
  xdesc := ed_descricao.text;
  if xdesc = '' then xdesc := ' ';
  layout.Consultar(xdesc, tq);
end;

procedure TFrmCons_LayOutChq.ed_descricaoKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
  if key = 12 then faz_consulta;
end;

procedure TFrmCons_LayOutChq.BtnFecharClick(Sender: TObject);
begin
  xcons_layout := tq.fieldbyname('Ban_Codigo').asstring;
  inherited;
end;

end.
